#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
int brr[N];
int n, m;
bool fun(int x)
{
	int l = -1, r = m;
	while (l + 1 < r) {
		int mid = l + r >> 1;
		if (brr[mid] < x)l = mid;
		else r = mid;
	}
	if (brr[r] == x)return 1;
	return 0;
}
int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> brr[i];
	}
	sort(brr, brr + m);
	for (int i = 0; i < n; i++) {
		if (fun(arr[i])) {
			cout << arr[i] << " ";
		}
	}
	return 0;
}